<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('菜单管理')" />
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">

        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-success" onclick="$.operate.add(0)" shiro:hasPermission="system:menu:add">
                <i class="fa fa-plus"></i> 新增户型
            </a>
            <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="system:menu:edit">
                <i class="fa fa-edit"></i> 修改
            </a>

        </div>

        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-tree-table"></table>
        </div>
    </div>
</div>

<th:block th:include="include :: footer" />

<script th:inline="javascript">
    //这个代码会被java的thymeleaf编译成文字
    var editFlag = [[ ${@permission.hasPermi('system:menu:edit')}]];
    var addFlag = [[ ${@permission.hasPermi('system:menu:add')}]];
    var removeFlag = [[${@permission.hasPermi('system:menu:remove')}]];
    var datas = [[${@dict.getType('sys_show_hide')}]];
    var prefix = ctx + "admin/house/size";

   //jquery初始化
    $(function(){
        //配置bootstrap-table表的ajax的查询以前数据列
        initBootStrapTreeTable();

    });

    function initBootStrapTreeTable(){
        //后台提供ajax访问请求post
        var options = {
            code: "id",
            parentCode: "parentId",
            uniqueId: "id",
            expandAll: false,
            expandFirst: false,
            url: prefix + "/list",
            createUrl: prefix + "/add/{id}",
            updateUrl: prefix + "/edit/{id}",
            sortName: "",
            modalName: "户型",
            columns: [{
                field: 'selectItem',
                radio: true
               },
                {
                    title: '户型名称',
                    field: 'name',
                    align: "left"
                },
                {
                    field: 'createTime',
                    title: '创建时间',
                    align: "left"
                },
                {
                    title: '操作',
                    align: "left",
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a>');
                        actions.push('&nbsp;<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-trash"></i>删除</a>');

                        if(row.parentId===0){
                            actions.push('&nbsp;<a class="btn btn-info btn-xs ' + addFlag + '" href="javascript:void(0)" onclick="$.operate.add(\'' + row.id + '\')"><i class="fa fa-plus"></i>新增</a>');
                        }
                        return actions.join('');
                    }
                }]
        };

        $.treeTable.init(options);

    }



</script>
</body>
</html>